package org.study.controller;

import dev.langchain4j.model.chat.ChatModel;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: jzhou
 * @date: 2025/7/6-15:24
 * @version: 1.0
 * @description: java-ai-study
 */
@RestController
public class PopularIntegrationController {

    ChatModel chatModel;

    public PopularIntegrationController(ChatModel chatModel) {
        this.chatModel = chatModel;
    }

    // 请求接口：http://localhost:8080/lc4j/boot/chat?message=Hello
    @GetMapping("/lc4j/boot/chat")
    public String model(@RequestParam(value = "message", defaultValue = "Hello") String message) {
        String chat = chatModel.chat(message);
        System.out.println("通过langchain4j调用模型返回结果：\n" + chat);
        return chat;
    }
}
